package com.example.fragmenttest;

import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


public class Fragment_SplashScreen extends Fragment {
	
	// Splash screen timer
    private static int SPLASH_TIME_OUT = 1000;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.fragment_splash,
				container, false);
		
		new Handler().postDelayed(new Runnable() {
			 
            /*
             * Showing splash screen with a timer.
             */
 
            @Override
            public void run() {
                // This method will be executed once the timer is over
                // Start your app main activity
            	transitionFragment();
            }
        }, SPLASH_TIME_OUT);
		
		return v;
	}
	
	private void transitionFragment() {
		FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
		transaction.replace(R.id.fragmentContainer, new Fragment_CentralControl());
		transaction.commit();
	}
}
